package com.gosophia.conferenceManagement.confPreparation.test.integration;

import java.util.ArrayList;
import java.util.List;

import junit.framework.Assert;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.transaction.annotation.Transactional;

import com.gosophia.commons.exception.BusinessException;
import com.gosophia.conferenceManagement.confPreparation.entity.NotificationFeedbackList;
import com.gosophia.conferenceManagement.confPreparation.entity.ParticipatingNameList;
import com.gosophia.conferenceManagement.confPreparation.service.ConfPreparationService;
import com.gosophia.conferenceManagement.confPreparation.service.impl.ConfPreparationServiceImpl;
import com.gosophia.userManagement.entity.UserInfo;
/**
 * 会务管理Service集成测试
 * @author wangxinbing
 * @since  2011-3-24
 *  Copyright (c) 2010 Gosophia corporation All Rights Reserved
 */
@ContextConfiguration(locations = { "classpath*:moduleContext.xml","classpath:applicationContext-it.xml" })
@Transactional(rollbackFor = { BusinessException.class })
public class ITConfPreparationServiceImpl  extends AbstractTransactionalJUnit4SpringContextTests{

	@Autowired
	private ConfPreparationService confPreparationService;
	@Test
	public void test(){
		System.out.println(confPreparationService);
	}
	/**
	 * 根据jobId查询参会列表
	 */
	@Test(expected=IllegalArgumentException.class)
	public void testFindParticipatingNameListsByJobIdNULL(){
		confPreparationService.findParticipatingNameListsByJobId(null);
	}
	@Test
	public void testFindParticipatingNameListsByJobId(){
		List<ParticipatingNameList> ptic = confPreparationService.findParticipatingNameListsByJobId(1L);
		Assert.assertEquals(true, ptic.size() == 4);
	}
	/**
	 * 根据jobId查询反馈列表
	 */
	@Test(expected=IllegalArgumentException.class)
	public void testFindNotificationFeedbackListsByJobIdNull(){
		confPreparationService.findNotificationFeedbackListsByJobId(null);
	} 
	@Test
	public void testFindNotificationFeedbackListsByJobId(){
		List<NotificationFeedbackList> notiList = confPreparationService.findNotificationFeedbackListsByJobId(1L);
		Assert.assertEquals(true, notiList.size() == 3);
	}

	@Test
	public void testAddNotificationFeedbackList() throws BusinessException{
		List<UserInfo> userinfolist = new ArrayList<UserInfo>();
		UserInfo user1= new UserInfo();
		user1.setUserInfoId(1L);
		UserInfo user2 = new UserInfo();
		user2.setUserInfoId(2L);
		UserInfo user3 = new UserInfo();
		user3.setUserInfoId(3L);
		userinfolist.add(user1);
		userinfolist.add(user2);
		userinfolist.add(user3);
		confPreparationService.addNotificationFeedbackList(1L, userinfolist);
	}
	

	@Test
	public void testUpdateNotificationFeedbackList() throws BusinessException{
		confPreparationService.updateNotificationFeedbackList(1L, 1L, "YES");
	}
	@Test
	public void testUpdateParticipatingNameList() throws BusinessException{
		List<ParticipatingNameList> participatingNameLists = new ArrayList<ParticipatingNameList>();
		ParticipatingNameList p1 = new ParticipatingNameList();
		p1.setUserName("user1");
		p1.setOrgName("org1");
		p1.setPositionName("position1");
		ParticipatingNameList p2 = new ParticipatingNameList();
		p2.setUserName("user2");
		p2.setOrgName("org2");
		p2.setPositionName("position2");
		ParticipatingNameList p3 = new ParticipatingNameList();
		p3.setUserName("user3");
		p3.setOrgName("org3");
		p3.setPositionName("position3");
		ParticipatingNameList p4 = new ParticipatingNameList();
		p4.setUserName("user4");
		p4.setOrgName("org4");
		p4.setPositionName("position4");
		participatingNameLists.add(p1);
		participatingNameLists.add(p2);
		participatingNameLists.add(p3);
		participatingNameLists.add(p4);
		confPreparationService.updateParticipatingNameList(1L, participatingNameLists);
	}
	//查找会议材料
	@Test
	public void testFindMaterialsByJobId() throws BusinessException{
		confPreparationService.findMaterialsByJobId(1L);
	}
}
